//
//  JYComposeTitleView.swift
//  WeiBoDemo
//
//  Created by 万佳阳 on 16/8/5.
//  Copyright © 2016年 JYWan. All rights reserved.
//

import UIKit
import SnapKit

class JYComposeTitleView: UIView {
    //懒加载属性
    private lazy var titleLabel : UILabel = UILabel()
    private lazy var nameLabel : UILabel = UILabel()
    
    // MARK:- 构造函数
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}

// MARK:- 设置UI界面
extension JYComposeTitleView {
    private func setupUI() {
        //添加到父控件
        addSubview(titleLabel)
        addSubview(nameLabel)
        
        //设置约束
        titleLabel.translatesAutoresizingMaskIntoConstraints = false
        nameLabel.translatesAutoresizingMaskIntoConstraints = false
        
        titleLabel.snp_makeConstraints { (make) in
            make.centerX.equalTo(self)
            make.top.equalTo(self)
        }
        nameLabel.snp_makeConstraints { (make) in
            make.top.equalTo(titleLabel.snp_bottom).offset(3)
            make.centerX.equalTo(titleLabel.snp_centerX)
        }
        
        //设置控件属性
        titleLabel.font = UIFont.systemFontOfSize(15)
        nameLabel.font = UIFont.systemFontOfSize(13)
        nameLabel.textColor = UIColor.lightGrayColor()
        
        //设置文字内容
        titleLabel.text = "发微博"
        nameLabel.text = JYUserAccountViewModel.shareInstance.userAccount?.name
        
    }
}
